<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>支付宝支付</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/store/qrcodepay/css/index.css">
    <link rel="stylesheet" href="/assets/base/repair/js/sweetalert/lib/sweet-alert.css">
</head>
<body>
<div class="load" id="show_loading" style="display:none;">
	<img class="load-bee" src="/assets/base/charging/images/load-bee.png">
</div>
<div class="wraper">
	<p class="seller"><img src="{BEESCRM:$data.logo}"/></p>
    <p class="padding text-center">{BEESCRM:$data.wechatName}</p>
    <div class="form-list">
		<p>应付金额</p>
		<div class="tb-mode">
			<p class="tb-cell text-20">￥</p>
			<p class="tb-cell"><input id="order_amount" type="number" placeholder="请输入金额"></p>
		</div>
        <if condition="$sremark eq 2 or $sremark eq 3">
            <div>
                <p class="tb-cell text-20"></p>
                <p class="tb-cell"><input id="remark" type="text" placeholder="请输入备注" /></p>
            </div>
        </if>
	</div>
	<div class="big-btn">
		<a href="javascript:void(0);" class="btn btn-gray">确认</a>
	</div>
</div>
<input type="hidden" id="wechatId" value="{BEESCRM:$data.wechatId}">
<input type="hidden" id="portId" value="{BEESCRM:$data.portId}">
<include file="commonJs" />
<!--<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>-->
<script>


$(function() {
	$("#order_amount").keyup(function () {
	    if(!isNaN($(this).val())){
	    	var reg = $(this).val().match(/^[1-9]\d*\.\d{0,2}|0\.\d?[1-9]?/);
		    var txt = '';
		    if (reg != null) {
		        txt = reg[0];
		        $(this).val(txt);
		    }else{
		    	var reg2 = $(this).val().match(/^0\d+/);
		    	if (reg2 != null) {
			    	txt = $(this).val()*1;
			    	if(txt == 0){
			    		$(this).val('');
				    }else{
				    	$(this).val(txt);
					}
		    	}
			}
		    
		    if ($(this).val() > 0){
				$('.btn').removeClass('btn-gray');
				$('.big-btn').addClass('submit');
		    }else{
		    	$('.btn').addClass('btn-gray');
				$('.big-btn').removeClass('submit');
			}
		}else{
			$(this).val('');
		}
	    
	});
	var sremark = "{BEESCRM:$sremark}";
	//提交订单
	$('.big-btn').one("click",function(){
		if($(this).hasClass('submit')){
			var portId = $('#portId').val();
			var order_amount = $('#order_amount').val();
			var wechatId = $('#wechatId').val();
			var remark = $('#remark').val();
            if(sremark == 3 && remark == ''){
                $.alert('error','终端备注必填');//如果等于1则隐藏
                return false;
            }
			$.ajax({
				'url': "/base/qrcodePay/doAliPay/",
				'data': { 'portId':portId,'order_amount':order_amount,'wechatId':wechatId,'remark':remark},
				'dataType':'json',
				'type': 'POST',
				'async': false,
				beforeSend: function(){	 
					 $('#show_loading').show();
				},
				success: function(data) {
					$('#show_loading').hide();
					if(data.status=='AS'){
						window.location.href=data.url;
					}
				},
                error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert(XMLHttpRequest.status);
					alert(XMLHttpRequest.readyState);
					alert(textStatus);
				}
			});
		}
	});
});
</script>
</body>
</html>